package com.parsechina.hpush.broker;

import com.google.common.collect.Lists;

import java.util.List;


public class Main {

	/**
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {

		List<String> words = Lists.newArrayList("bachelor","jar","badge","baby");
//		String[] words = new String[]{"bachelor","jar","badge","baby"};
		//String[] words = new String[]{"badge","baby","bachelor","jar"};
		//String[] words = new String[]{"a","b","c","d","ab"};
		//String[] words = new String[]{"abc","a","a","ab"};
		//String[] words = new String[]{"a","a","a"};
//		ArrayList<String> words = new ArrayList<String>();
		//BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("C:/Users/ding/Downloads/result.txt")));
//		BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("E:/兔子的试验学习中心[课内]/ACM大赛/ACM第四届校赛/E命令提示/words3.dic")));
//		String s;
//		int num = 0;
//		while((s=reader.readLine()) != null)
//		{
//			words.add(s);
//			num ++;
//		}
		DoubleArrayTrie dat = new DoubleArrayTrie();

		dat.build(words);

		List<Integer> indexs = dat.commonPrefixSearch("badge");
		for (Integer index: indexs) {
			System.out.println(words.get(index));
		}
		words.clear();
		words.add("a");

		System.out.println((int)'/');
		System.out.println((int)'+');
		System.out.println((int)'#');
		System.out.println((int)'a');
		System.out.println((int)'z');
		System.out.println((int)'A');
		System.out.println((int)'Z');
		System.out.println((int)'0');
		System.out.println((int)'1');
		System.out.println((int)'9');


	}

}
